package com.healthy.reminders.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.healthy.common.log.annotation.Log;
import com.healthy.common.log.enums.BusinessType;
import com.healthy.common.security.annotation.RequiresPermissions;
import com.healthy.reminders.domain.PlanProgress;
import com.healthy.reminders.service.IPlanProgressService;
import com.healthy.common.core.web.controller.BaseController;
import com.healthy.common.core.web.domain.AjaxResult;
import com.healthy.common.core.utils.poi.ExcelUtil;
import com.healthy.common.core.web.page.TableDataInfo;

/**
 * 追踪计划Controller
 * 
 * @author 束伟
 * @date 2024-03-29
 */
@RestController
@RequestMapping("/PlanProgress")
public class PlanProgressController extends BaseController
{
    @Autowired
    private IPlanProgressService planProgressService;

    /**
     * 查询追踪计划列表
     */
    @RequiresPermissions("reminders:PlanProgress:list")
    @GetMapping("/list")
    public TableDataInfo list(PlanProgress planProgress)
    {
        startPage();
        List<PlanProgress> list = planProgressService.selectPlanProgressList(planProgress);
        return getDataTable(list);
    }

    /**
     * 导出追踪计划列表
     */
    @RequiresPermissions("reminders:PlanProgress:export")
    @Log(title = "追踪计划", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PlanProgress planProgress)
    {
        List<PlanProgress> list = planProgressService.selectPlanProgressList(planProgress);
        ExcelUtil<PlanProgress> util = new ExcelUtil<PlanProgress>(PlanProgress.class);
        util.exportExcel(response, list, "追踪计划数据");
    }

    /**
     * 获取追踪计划详细信息
     */
    @RequiresPermissions("reminders:PlanProgress:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(planProgressService.selectPlanProgressById(id));
    }

    /**
     * 新增追踪计划
     */
    @RequiresPermissions("reminders:PlanProgress:add")
    @Log(title = "追踪计划", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PlanProgress planProgress)
    {
        return toAjax(planProgressService.insertPlanProgress(planProgress));
    }

    /**
     * 修改追踪计划
     */
    @RequiresPermissions("reminders:PlanProgress:edit")
    @Log(title = "追踪计划", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PlanProgress planProgress)
    {
        return toAjax(planProgressService.updatePlanProgress(planProgress));
    }

    /**
     * 删除追踪计划
     */
    @RequiresPermissions("reminders:PlanProgress:remove")
    @Log(title = "追踪计划", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(planProgressService.deletePlanProgressByIds(ids));
    }
}
